package com.zjp.demo02251.dao;

import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author james
 * @Title: CompanyUserMapper
 * @Package com.zjp.demo02251.dao
 * @Description:
 * @date 2018/2/25  18:06
 */
@Component
@Mapper
public interface CompanyUserMapper {

    /**
     * @Description: 查询所有的公司员工
     * @author james
     * @param
     * @return List<CompanyUser>
     * @date 2018/2/25  18:08
    */
    @Select("select * from company_user")
    public List<CompanyUser> findAll();


    /**
     * @Description: 根据id查询员工
     * @author james
     * @param
     * @return CompanyUser
     * @date 2018/2/25  18:09
    */
    @Select("select * from company_user where id =#{id}")
    public CompanyUser findOneById(Integer id);


    /**
     * @Description: 根据name查询员工
     * @author james
     * @param  name
     * @return List<CompanyUser>
     * @date 2018/2/25  18:09
    */
    @Select("select * from company_user where name = #{name}")
    public List<CompanyUser> findOneByName(Integer name);


    /**
     * @Description: 保存员工信息
     * @author james
     * @param  CompanyUser  companyuser
     * @return int stauts
     * @date 2018/2/25  18:13
    */
    @Insert("insert into company_user(name,age,sex) values(#{name},#{age},#{sex})")
    public int save(CompanyUser companyUser);


    /**
     * @Description: 根据id更新员工信息
     * @author james
     * @param CompanyUser  companyuser
     * @return int stauts
     * @date 2018/2/25  18:15
    */
    @Update("UPDATE company_user  SET `name`=#{name},age=#{age},sex=#{sex} where id = #{id} ")
    public int updateUserById(CompanyUser companyUser);


    /**
     * @Description: 根据id删除员工信息（物理删除）
     * @author james
     * @param id
     * @return int stauts
     * @date 2018/2/25  18:16
    */
    @Delete("delete from company_user where id =#{id} ")
    public int delUser(Integer id);
}
